<template>
	<view>
		<view class="load">登录</view>
		<view class="center">
		<!-- 	<text>名称</text> -->
			<uni-data-picker placeholder="加工中心" popup-title="请选择加工中心" :localdata="dataName"
			 	 @nodeclick="onnodeclickName">
			 </uni-data-picker>
		</view>
		<button class="buttonLogin" @click="requesthome">登录</button>
		  <!-- <uni-data-picker v-slot:default="{data, error, options}" popup-title="请选择所在地区">
		    <view v-if="error" class="error">
		      <text>{{error}}</text>
		    </view>
		    <view v-else-if="data.length" class="selected">
		      <view v-for="(item,index) in data" :key="index" class="selected-item">
		        <text>{{items.text}}</text>
		      </view>
		    </view>
		    <view v-else>
		      <text>请选择</text>
		    </view>
		  </uni-data-picker> -->
	</view>
</template>

<script>
  export default {
      data() {
        return {
          dataName: [{
            text: "加工中心1",
            value: "1-0",
            children: [
              {
                text: "1.1班",
                value: "1-1"
              },
              {
                text: "1.2班",
                value: "1-2"
              }
            ]
          },
          {
            text: "加工中心2",
            value: "2-0"
          },
          {
            text: "加工中心3",
            value: "3-0"
          }],
		  name: '',
		  code: '',
		  level: '',
		  index: 1,
		  activeArr: [],
        }
      },
      methods: {
		  requesthome(){
		  	if(this.name != null && this.name != ''){
				if(this.code != null && this.code != ''){
					uni.showToast({
						title: this.name+"/"+this.code,
						mask: false,
						duration: 1500
					});
					//跳转
					//保存用户信息到全局的缓存中
					uni.setStorageSync("center",this.name);
					uni.navigateTo({
					    url: '../center_home/center_home'
					})
						
				}else{
					uni.showToast({
						title: "未选中2",
						mask: false,
						duration: 1500
					})
				}
				
			}else{
				uni.showToast({
					title: "未选中",
					mask: false,
					duration: 1500
				})
			}
		  	
		  },
		  pathccc(res){
		  	console.log("点击Button按钮：",res)
		  	uni.navigateTo({
		  	    url: '../center_home/center_home'
		  	});
		  
		  },
        onchange(e) {
    //       const value = e.detail.value
		  // const code = e.detail.parent_value
        },
        onnodeclickName(e) {
        	console.log('onnodeclick',e);
        	this.name = e.value
			this.code = e.parent_value
        	this.index = 1;
        	this.activeArr=[];
        	this.sendPost();
        },
		async sendPost(){
			const res = await this.$myRequest({
				url: '/makerwit/wms/queryAGVDeviceState',
				data: '{}',
				method: 'POST'
			})
			for(let i=0;i<res.data.data.length;i++){
				//this.activeArr = res.data.data
				if(res.data.data[i].id == this.id){
					console.log("asjdfjwoijfwiefnvjksdjkgfreifvjsdjf:",res.data.data[i].name)
					this.activeArr=res.data.data[i]
					console.log(this.activeArr)
				}
			}
		},
		
      },
	  onShow() {
	  this.sendPost()	
	  },
	  
    }
</script>

<style>
	.load{
		width: 80%;
		height: 60px;
		margin: 0 auto;
		text-align: center;
	}
.center{
	width: 80%;
	height: 120px;
	margin: 0 auto;
}
uni-data-picker{
	font-size: 36px;
}
.buttonLogin{
	width: 50%;
	margin: 0 auto;
}
</style>
